#!/usr/bin/perl

# this script for read and anylisy the *.data.log file and translate the date to time strting.

# <> 表示，如果命令中带一个文件名，尝试打开该文件并读取该文件内容，如果没有则自动读取STDIN中内容。

while(<>){
	my($time1,$data)=split(/,/,$_,2);
	print "$time1(".gettime($time1)."),$data";
}



# get the date string "2016-05-21-06:32:00", base on the seconds from 1970.
sub gettime{
	my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(shift);
	$year += 1900; # $year是从1900开始计数的，所以$year需要加上1900；
	$mon += 1; # $mon是从0开始计数的，所以$mon需要加上1；
	my $datetime = sprintf ("%d-%02d-%02d-%02d:%02d:%02d", $year,$mon,$mday,$hour,$min,$sec);
	return $datetime;
}